﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZHDJ.Data.Models.BaseInfo;
using ZHDJ.Data.Models.Center;
using ZHDJ.Data.Models.Forum;
using ZHDJ.WebPage;
using ZHDJ.WebPage.Master;

namespace ZHDJ.Web.Portal.BranchHome
{
    public partial class BranchLeader : UseMorePageMasterPage
    {
        /// <summary>
        /// BranchID
        /// </summary>
        private string BranchID
        {
            get
            {
                return this.Request["BranchID"] ?? "null";
            }
        }
        private DataSet _DataSource;

        public DataSet DataSource
        {
            get
            {
                if (_DataSource == null)
                {
                    _DataSource=PartyOrgLeader.GetGridData(0, int.MaxValue, BranchID);
                }
                 return _DataSource;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.rptPost.ItemDataBound += RptPost_ItemDataBound;
                LoadData();
            }
        }

       
        public void LoadData()
        {
           
           var postCategory = DB.DataDictionarys.Where(a => a.DDicType == "ZHDJ.OrgLeader.PostCategory").OrderBy(a => a.OrderNo).ToList();
            rptPost.DataSource = postCategory;
            rptPost.DataBind();
        }

        private void RptPost_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            var dataList = e.Item.FindControl("rptLeader") as Repeater;
            if (dataList == null)
            {
                return;
            }
            var row = e.Item.DataItem as DataDictionary;
            var datav = DataSource.Tables[0].AsDataView();
            datav.RowFilter = string.Format("PostCategory='{0}'", row.DDicMember);
            dataList.DataSource = datav.ToTable();
            dataList.DataBind();
        }


        /// <summary>
        /// 初始化module  如果通过url传参可不设置
        /// </summary>
        protected override void InitModule()
        {
            
            Category = "BranchLeader";
            Module = "BranchHomeMore";
        }
    }
}